/*
 * 描述： <描述>
 * 修改人： rain
 * 修改时间： 2016年9月13日
 * 项目： yaxinp2p
 */
package com.rainhy.webcore.token.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.rainhy.webcore.token.context.AccessTokenContext;


/**
 * AccessToken 拦截器
 * 
 * @author rain
 * @version [版本号, 2016年9月13日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class AccessTokenInterceptor extends HandlerInterceptorAdapter {
    
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        AccessTokenContext.endRequest(request, response, handler, ex);
        super.afterCompletion(request, response, handler, ex);
    }
    
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        AccessTokenContext.postRequest(request, response, handler, modelAndView);
        super.postHandle(request, response, handler, modelAndView);
    }
    
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        AccessTokenContext.startRequest(request, response, handler);
        return super.preHandle(request, response, handler);
    }
}
